package com.wbc.smartHome.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Component;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

@Component
@Data
@ApiModel
public class Admin implements Serializable {
    /*开启缓存需要返回的model类实现序列化接口Serializable*/
    @ApiModelProperty(value = "管理员id")
    private Integer id;
    @ApiModelProperty(value = "管理员账号")
    private String account;
    @ApiModelProperty(value = "管理员密码")
    private String password;
    private String phone;
    private Integer type;
    private Integer menuIds[];
    private String typeName;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")//接收前端提交数据的日期格式
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")//后端向前端转json时的日期格式
    private Date operTime;
    private String adminToken;
    private Admin admin;
    private List<Menu> menus;
    //lombok组件 在编译期间动态生成get、set方法


    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public Admin(int id, String account, String password, Integer type, String phone, String adminToken, Date operTime, Admin admin) {
        this.id = id;
        this.account = account;
        this.password = password;
        this.type = type;
        if (type==1){
            this.typeName="超级管理员";
        }
        else if (this.type==2){
            this.typeName="管理员";
        }
        this.phone = phone;
        this.adminToken = adminToken;
        this.operTime = operTime;
        this.admin = admin;
    }

    public Admin() {
    }

    public Integer getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
        if (type==1){
            this.typeName="超级管理员";
        }
        else if (this.type==2){
            this.typeName="管理员";
        }
    }

    public Date getOperTime() {
        return operTime;
    }

    public void setOperTime(Date operTime) {
        this.operTime = operTime;
    }

    public String getAdminToken() {
        return adminToken;
    }

    public void setAdminToken(String adminToken) {
        this.adminToken = adminToken;
    }

    public Admin getAdmin() {
        return admin;
    }

    public void setAdmin(Admin admin) {
        this.admin = admin;
    }
}
